﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class FXManager : MonoBehaviour
{
    public static FXManager Instance;
    public List<EffectConfig> effectConfigs;


    private void Awake()
    {
        Instance = this;
    }

    // Start is called before the first frame update
    void Start()
    {
        
    }

    // Update is called once per frame
    void Update()
    {
        
    }


    public static GameObject PlayFX(string effectName, Transform attachTransform)
    {
        foreach (EffectConfig fxcfg in Instance.effectConfigs)
        {
            if (fxcfg.effectName == effectName && fxcfg.effectPrefab)
            {
                GameObject obj = Instantiate(fxcfg.effectPrefab, attachTransform);
                return obj;
            }
        }
        return null;
    }
}


[System.Serializable]
public struct EffectConfig
{
    public string effectName;
    public GameObject effectPrefab;

}